﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sunny.UI;
namespace OtherDevice
{
    public partial class Form_OvenSix : Form_ControlBase
    {
        public Form_OvenSix()
        {
            InitializeComponent();
        }
        Oven_Base Device_Oven = null;
        public override void FlushToDlg(object devicebase)
        {
            try
            {
                if (devicebase == null)
                    return;
                this.Device_Oven = devicebase as Oven_Base;
                this.Dock = DockStyle.Fill;
                this.Show();
            }
            catch (Exception)
            {

            }
        }

        private void Form_OvenSix_Initialize(object sender, EventArgs e)
        {

        }

        private void btn_SetProgram_Click(object sender, EventArgs e)
        {
            try
            {
                int n_Box = Convert.ToInt32(chb_OvenIndex.Text);
                int n_Program = Convert.ToInt32(chb_程序编号.Text);
                Device_Oven.Function_运行指定程序(n_Box, n_Program);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btn_ProgramMode_Click(object sender, EventArgs e)
        {
            try
            {
                int n_Box = Convert.ToInt32(chb_OvenIndex.Text);
                Device_Oven.Function_程式(n_Box);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void btn_定值模式_Click(object sender, EventArgs e)
        {
            try
            {
                int n_Box = Convert.ToInt32(chb_OvenIndex.Text);
                Device_Oven.Function_定值(n_Box);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void btn_StartHeart_Click(object sender, EventArgs e)
        {
            try
            {
                int n_Box = Convert.ToInt32(chb_OvenIndex.Text);
                Device_Oven.Function_开始加热(n_Box);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void btn_StopHeart_Click(object sender, EventArgs e)
        {
            try
            {
                int n_Box = Convert.ToInt32(chb_OvenIndex.Text);
                Device_Oven.Function_停止加热(n_Box);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void btn_ReflushData_Click(object sender, EventArgs e)
        {
            try
            {

                int n_Box = Convert.ToInt32(chb_OvenIndex.Text);
                double d_ActTemp = 0;
                double d_SetTemp = 0;
                bool b_IsOpen = false;
                string str_Mode = "";
                bool b_IsConnect = false;
                Device_Oven.Function_获取炉子状态(n_Box,ref b_IsConnect,ref d_ActTemp,ref d_SetTemp,ref b_IsOpen,ref str_Mode);
                lbl_ActTemp.Text = d_ActTemp.ToString();
                lbl_SetTemp.Text = d_SetTemp.ToString();
                lbl_IsOpen.Text = b_IsOpen.ToString();
                lbl_Mode.Text = str_Mode;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void btn_SetTem_Click(object sender, EventArgs e)
        {
            try
            {

                double d_Tem = Convert.ToDouble(txt_Temp.Text);
                int n_Box = Convert.ToInt32(chb_OvenIndex.Text);
                Device_Oven.Function_设置温度(n_Box, d_Tem);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
